/*
 * FSM.c
 *
 *  Created on: Feb 4, 2013
 *      Author: justin
 */

#include "project.h"
void FSM_task(void* pvParameters) {
	typedef enum fsm_mode_names {
		init = 0, run = 1, stop = 2, restart = 3, quit = 4, display = 5
	} machine_state;    //enumerate declarations to simplify code readability of FSM state

	int fsm_mode = init;
	while (1) {
		switch (fsm_mode) {
			case init:
//				init_ticker(1000);    //start hardware timer with 1000usec resolution
//				init_io();
//				init_uart(0);
				fsm_mode = run;

				break;
				/**----------------------------*/
			case (run):

				sbi(PORTA,4);
				vTaskDelay(10 / portTICK_RATE_MS);
				cbi(PORTA,4);
				vTaskDelay(10 / portTICK_RATE_MS);
				break;
				/**----------------------------*/
			case display:
//				sprintf(*display_msg,4);

				break;
			case stop:
				PORTA = 0x00;

//				stoptimer_val = tick_ms;
//				if (tick_ms >= runtimer_val + 500) {
//					if (stoptimer_val) {
//
//					}
//
//				}
				break;
			case quit:
				//puts("MCU halting")
				while (1)
					;    //spin lock to hold system state
				break;
				/**----------------------------*/
			case restart:
//				sprintf("MCU is restarting");
				fsm_mode = init;
				break;
			default:
				break;
		}
	}
}

void USart_putc(char i) {

}
//void USart_puts(char *i){
//	int j=0;
//	while(i[j++]){
//		xSerialPutChar(0,*i,3);
//	}
//
//}
//void serial_task(void* pvParameters) {
//	while (1) {
//		if (xRxedChars==1){
//			xQueueGenericReceive(xRxedChars,voif *const pvBuffer,0,0);
//		}
//	}
//
//}
